Skip to content

fix(wincred): Use UTF-16 encoding for passwords (carry 335)#427

Draft
thaJeztah wants to merge 4 commits intodocker:mainfrom
thaJeztah:carry_335
Draft

fix(wincred): Use UTF-16 encoding for passwords (carry 335)#427
thaJeztah wants to merge 4 commits intodocker:mainfrom
thaJeztah:carry_335

Conversation

@thaJeztah
Copy link
Copy Markdown
Member

This change adds UTF-16 encoding to the Windows credential helper.

As recommended by the author of the wincred library, the password should be encoded to allow other applications to use the same password.

This is especially needed when the docker image repository is hosted on a JFrog Artifactory, that also hosts Python repositories. Because nobody wants to store their credentials in as plain test within the pip.ini, they're going to enable the keyring support for pip, which in turn uses the Win32API that assumes that the password is a UTF-16 encoded string. Since this is not the case pip will crash with an encoding error.

- What I did

- How I did it

- How to verify it

- Description for the changelog

- A picture of a cute animal (not mandatory but encouraged)

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 20, 2026

Codecov Report

❌ Patch coverage is 45.28302% with 29 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
wincred/wincred.go 45.28% 25 Missing and 4 partials ⚠️

📢 Thoughts on this report? Let us know!

Comment thread wincred/wincred.go
Comment on lines +34 to +37
if err != nil {
fmt.Println(err)
os.Exit(1)
}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed this to an error return instead

@thaJeztah thaJeztah force-pushed the carry_335 branch 3 times, most recently from 2b9c650 to 9d79315 Compare April 20, 2026 16:29
thaJeztah and others added 4 commits April 20, 2026 19:13
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This change adds UTF-16 encoding to the Windows credential helper.

As recommended by the author of the wincred library, the password
should be encoded to allow other applications to use the same password.

This is especially needed when the docker image repository is hosted on
a JFrog Artifactory, that also hosts Python repositories. Because nobody
wants to store their credentials in as plain test within the _pip.ini_,
they're going to enable the keyring support for pip, which in turn uses
the Win32API that assumes that the password is a UTF-16 encoded string.
Since this is not the case pip will crash with an encoding error.

Signed-off-by: Philipp Krüger <github.khab3@passinbox.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
As older versions of the credential helper would store creds as raw
bytes, we must expect the value to be a raw byte, not UTF-16LE encoded.

Try decoding the value and check if it round-trips correctly to make
sure we're actually dealing with UTF-16LE encoded creds.

We should also consider setting a custom "encoding" attribute instead
to detect what encoding was used to store the value.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants